﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Tool.Framework;
@using VirtualPress.Infrastructure.Entities.Enum;
@using VirtualPress.Infrastructure.Entities.JSONModel;
@{
    Article article = ViewBag.Article;
    ViewBag.Title = "稿件详情 -- " + article.Title;
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
@{List<AuditingRecord> record = ViewBag.AuditingRecord;
  Periodical journal = ViewBag.Journal;
  List<ArticleAuthor> author = ViewBag.ArticleAuthor;
  List<Appendix> Attachment = ViewBag.Attachment;}
<link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>
        稿件详情</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/Member/Index" class="tip-bottom"><i class="icon-home"></i>起始页</a>
    <a class="current">稿件详情</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span8">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-pencil"></i></span>
                    <h5>
                        期刊投稿</h5>
                    <h5 style="float: right; color: Red;">
                        *为必填</h5>
                </div>
                <div class="widget-content nopadding">
                    <form class="form-horizontal" method="post" enctype="multipart/form-data" action="/WorkSpace/member/ArticleRevise">
                    <input type="hidden" name="ArticleId" value="@article.Id" />
                    <div class="step">
                        <div class="control-group">
                            <label class="control-label">
                                期刊名称</label>
                            <div class="controls">
                                <label>@journal.Name</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                稿件标题</label>
                            <div class="controls">
                                <label>@article.Title -- <b style="color: Green;">@article.Status.Mapping()</b></label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                英文标题</label>
                            <div class="controls">
                                <label>@article.Title_EN</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                稿件范围</label>
                            <div class="controls">
                                <label>@article.GJFW.Replace(";", "、 ")</label>
                            </div>
                        </div>
                        <div id="authorbox" class="control-group">
                            <label class="control-label">
                                稿件作者</label>
                            <div class="controls">
                                @foreach (var item in author)
                                { 
                                    @Html.Raw(item.AuthorName + " ")
                                }
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                摘要</label>
                            <div class="controls">
                                <p>@article.Abstract</p>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                关键字</label>
                            <div class="controls">
                                <label>@article.KeyWords</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                摘要(ENGLISH)</label>
                            <div class="controls">
                                <p>@article.Abstract_EN</p>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                关键字(ENGLISH)</label>
                            <div class="controls">
                                <label>@article.KeyWords_EN</label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                稿件</label>
                            <div class="controls">
                                @if (Attachment != null && Attachment.Any())
                                {
                                    var chugao = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.ChuGao).ToList();
                                    var xiuding = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.XiuDingGao).ToList();
                                    var zhonggao = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.ZhongGao).ToList();
                                    var dinggao = Attachment.Where(c => c.AttachmentStatus == AttachmentStatus.DingGao).ToList();
                                    if (chugao.Any())
                                    {
                                    <div style="height: 30px; line-height: 30px; border-top: 1px solid #fff; border-bottom: 1px solid #ccc;
                                        padding-bottom: 10px;">
                                        <div class="span2">
                                            初稿：</div>
                                        <div class="span8">
                                            <ul>
                                                @foreach (var att in chugao)
                                                {
                                                    <li><a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = att.Id, type = 9 }.ToJson())">
                                                        <i class="icon-file icon-large"></i>
                                                        @att.FileName;</a><span style="color: #999; font-style: italic; padding-left: 25px;">@att.CreateTime.ToString("yyyy-MM-dd")</span>
                                                    @if(!String.IsNullOrEmpty(att.Suggestion)){
                                                    <i class="icon-envelope icon-larger"><a target="_blank" href="/workspace/magazine/showsuggestion/@att.Id">查看审稿详情</a></i>
                                                    }
                                                    </li>
                                                }
                                            </ul>
                                        </div>
                                    </div>
                                    }
                                    if (xiuding.Any())
                                    {
                                    <div style="border-bottom: 1px solid #ccc; padding-bottom: 10px;">
                                        <div class="span2">
                                            修订稿：</div>
                                        <div class="span8">
                                            <ul>
                                                @foreach (var att in xiuding)
                                                {
                                                    <li><a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = att.Id, type = 9 }.ToJson())">
                                                        <i class="icon-file icon-large"></i>
                                                        @att.FileName;</a> <span style="color: #999; font-style: italic; padding-left: 25px;">@att.CreateTime.ToString("yyyy-MM-dd")</span>
                                                    @if(!String.IsNullOrEmpty(att.Suggestion)){
                                                    <i class="icon-envelope icon-larger"><a target="_blank" href="/workspace/magazine/showsuggestion/@att.Id">查看审稿详情</a></i>
                                                    }
                                                    </li>
                                                }
                                            </ul>
                                        </div>
                                    </div>
                                    }
                                    if (zhonggao.Any())
                                    {
                                    <div style="padding-bottom: 10px;">
                                        <div class="span2">
                                            终稿：</div>
                                        <div class="span8">
                                            <ul>
                                                @foreach (var att in zhonggao)
                                                {
                                                    <li><a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = att.Id, type = 9 }.ToJson())">
                                                        <i class="icon-file icon-large"></i>
                                                        @att.FileName;</a> <span style="color: #999; font-style: italic; padding-left: 25px;">@att.CreateTime.ToString("yyyy-MM-dd")</span>
                                                    </li>
                                                }
                                            </ul>
                                        </div>
                                    </div>
                                    }
                                    if (dinggao.Any())
                                    {
                                    <div style="padding-bottom: 10px;">
                                        <div class="span2">
                                            定稿：</div>
                                        <div class="span8">
                                            <ul>
                                                @foreach (var att in dinggao)
                                                {
                                                    <li><a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = att.Id, type = 9 }.ToJson())">
                                                        <i class="icon-file icon-large"></i>
                                                        @att.FileName;</a> <span style="color: #999; font-style: italic; padding-left: 25px;">@att.CreateTime.ToString("yyyy-MM-dd")</span>
                                                    </li>
                                                }
                                            </ul>
                                        </div>
                                    </div>
                                    }
                                }
                            </div>
                        </div>
                        @if (ViewBag.Recommendation != null)
                        {
                            <div class="control-group">
                                <label class="control-label">
                                    专家推荐材料</label>
                                <div class="controls">
                                    <a target="_blank" title="点击下载" href="/download?token=@EncodeByBase64.Encode(new { id = ViewBag.Recommendation.Id, type = 9 }.ToJson())">
                                        <i class="icon-file icon-large"></i>
                                        @ViewBag.Recommendation.FileName;</a>
                                </div>
                            </div>
                        }
                    </div>
                    <div class="form-actions">
                        <a class="btn btn-primary" href="/workspace/magazine/article">返回</a>
                    </div>
                    <div id="submitted">
                    </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="span4">
            <div class="accordion widget-box" id="collapse-group">
                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGOne" data-toggle="collapse"><span
                                class="icon"><i class="icon-magnet"></i></span>
                                <h5>
                                    稿件历史记录</h5>
                            </a>
                        </div>
                    </div>
                    <div class="accordion-body collapse" id="collapseGOne">
                        <div class="widget-content">
                            <ul class="activity-list">
                                @{
                                    List<ArticleHistory> his = ViewBag.History;
                                    if (his != null && his.Any())
                                    {
                                        foreach (var item in his)
                                        {
                                    <li><a href="javascript:;"><i class="icon-chevron-right"></i>
                                    <strong>@item.Message</strong>
                                        <span>@item.CreateTime.ToString("yyyy-MM-dd")</span> </a></li>
                                        }
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="accordion-group widget-box">
                    <div class="accordion-heading">
                        <div class="widget-title">
                            <a data-parent="#collapse-group" href="#collapseGTwo" data-toggle="collapse"><span
                                class="icon"><i class="icon-magnet"></i></span>
                                <h5>
                                    审稿记录</h5>
                            </a>
                        </div>
                    </div>
                    <div class="accordion-body in collapse" id="collapseGTwo">
                        <div class="widget-content">
                            <ul class="activity-list">
                                @{
                                    if (record != null && record.Any())
                                    {
                                        foreach (var item in record)
                                        {
                                    <li><a href="javascript:;"><i class="icon-chevron-right"></i><strong>@item.Step.Mapping()</strong>
                                        @item.ExamineStatus.Mapping()
                                        <span>@item.CreateTime.ToString("yyyy-MM-dd")</span>
                                        @if (!String.IsNullOrEmpty(@item.Message))
                                        {
                                            <i style="float:right;" title="@item.Message" class="icon-comment"></i>
                                        }
                                    </a></li>
                                        }
                                    }
                                    else
                                    {
                                    <li><a href="javascript:;"><i class="icon-chevron-right"></i>暂无记录 </a></li>
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section tail
{
    <script type="text/javascript">
        $(function () {
            $('#likarticle').addClass('active open');

            $('#finishform').submit(function(){
                var res = $('#sltres').val();
                var msg = $('#tarmsg').val();
                if(res != 0){
                    if(msg == ''){
                        $('#tarmsg').parent().parent().addClass('error');
                        $('#tarmsg').parent().children('span').remove();
                        $('#tarmsg').parent().append(
                            $('<span generated="true" class="help-inline">requird.</span>')
                        );
                        return false;
                    }
                }
            });
        });
        function cancelexamine(id) {
            if (confirm('您确认取消该专家的审稿权限吗？')) {
                window.location.href = '/workspace/magazine/cancelExamine/' + id + '?articleId=@article.Id';
            }
        }
        function urgeExamine(id,sender){
            if(confirm('是否确认向该专家发送催审通知邮件')){
                $.ajax({
                    url:'/workspace/magazine/urgeExamine/'+id,
                    success:function(){
                        $(sender).parent().html('<span class="label label-success">催审邮件已发出</span>');
                    }
            });
            }
        }
        function cancelAddExpert(sender) {
             $('#newexpertbox').hide();
        }
        function appendExpertOpt(){
            $('#newexpertbox').show();
        }
        function addExpert(){
            var expert = $('#sltExpert').val();
            var finishDate = $('#txtFinishDate');

            if (!/^\d+$/.test(finishDate.val())) {
                finishDate.parent().parent().parent().addClass('error');
                finishDate.parent().parent().append(
                            $('<span generated="true" class="help-inline">输入有误.</span>')
                        );
                return false;
            }
            $.ajax({
                url:'/workspace/magazine/appendExamineExpert',
                data:{
                    articleId:@article.Id,
                    expert:expert,
                    finishDate:finishDate.val()
                },
                type:'get',
                success:function(res){
                   window.location.href=window.location.href;
                }
            });
        }
        function changeexamineresult(sender){
            if($(sender).val() == 0) {
                $('#resmsgbox').hide();
            }
            else{
                $('#resmsgbox').show();
            }
        }
        function changefinishdate(sender) {
            var day = $(sender).val();
            if (parseInt(day, 10) > 0) {
                day = parseInt(day, 10);
                var myhelper = new dateHelper();
                var newdate = myhelper.AddDays(new Date(), day);
                $('#boxfinishdate').text(myhelper.Format(newdate, "yyyy-MM-dd"));
            }
        }
    </script>
}
